import { AxiosRequestConfig, AxiosResponse } from "axios";

/**
 * 拦截器回调
 */
export interface InterceptorHandlers {
  request?(request: AxiosRequestConfig): AxiosRequestConfig;

  response?(request: AxiosResponse<any>): any;
}

/**
 * HTTP请示封装接口
 */
export interface IHttpRequest {
  /**
   * 是否开启调试
   */
  debug: boolean;

  /**
   * 配置网络请求
   * @param opts
   */
  config(opts: AxiosRequestConfig): void;

  /**
   * 发起网络请求
   * @param options
   */
  request(options: AxiosRequestConfig): Promise<any>;

  /**
   * 发起网络请求（FROM方式）
   * @param url
   * @param data
   * @param options
   */
  formRequest(url: string, data: any, options?: any): Promise<any>;

  /**
   * 发起POST请求
   * @param url
   * @param data
   * @param options
   */
  post(url: string, data?: any, options?: AxiosRequestConfig): Promise<any>;

  /**
   * 发起GET请求
   * @param url
   * @param data
   * @param options
   */
  get(url: string, data?: any, options?: AxiosRequestConfig): Promise<any>;

  /**
   * 发起PUT请求
   * @param url
   * @param data
   * @param options
   */
  put(url: string, data?: any, options?: AxiosRequestConfig): Promise<any>;

  /**
   * 发起DELETE请求
   * @param url
   * @param data
   * @param options
   */
  delete(url: string, data?: any, options?: AxiosRequestConfig): Promise<any>;

  /**
   * 上传文件
   * @param url
   * @param data
   */
  upload(url: string, data: any): Promise<any>;

  /**
   * 配置拦截器
   * @param store
   * @param context
   * @param interceptors
   */
  interceptors(store: any, interceptors?: InterceptorHandlers): void;

  /**
   * 获取完整地址
   * @param url URL地址
   * @param baseUrl   基础URL地址名称,可选，当baseUrl值为空时默认使用网关地址作为baseUrl
   */
  getServerUrl(url: string, baseUrl?: string): string;
}

export interface ListResultDto<TModel> {
  items: Array<TModel>;
}

export interface PagedListResultDto<TModel> extends ListResultDto<TModel> {
  totalCount: number;
}

/**
 *
 */
export interface LimitedResultRequestDto {
  maxResultCount: number;
}

/**
 *
 */
export interface PagedResultRequestDto extends LimitedResultRequestDto {
  skipCount: number;
}

/**
 *
 */
export interface PagedAndSortedResultRequestDto extends PagedResultRequestDto {
  sorting: string;
}

export interface FullAuditedAggregateRoot<TKey> {
  id?: TKey;
  creationTime?: string;
  creatorId?: string;
  lastModificationTime?: string;
  lastModifierId?: string;
  isDeleted?: boolean;
  deleterId?: string;
  deletionTime?: string;
  extraProperties?: Record<string, any>;
}

export interface AuditedAggregateRoot<TKey> {
  id?: TKey;
  creationTime?: string;
  creatorId?: string;
  lastModificationTime?: string;
  lastModifierId?: string;
  extraProperties?: Record<string, any>;
}

export interface CreationAuditedAggregateRoot<TKey> {
  id?: TKey;
  creationTime?: string;
  creatorId?: string; 
  extraProperties?: Record<string, any>;
}
